package com.uneed;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.AbsListView;
import android.widget.FrameLayout;
import android.widget.ListView;
import android.widget.TextView;
import java.lang.ref.WeakReference;

public class HcListActivity extends Activity
{
  protected FrameLayout emptyView;
  private WeakReference<View> errorView;
  protected ListView listView;
  private WeakReference<View> loadingView;

  protected View createCategoryItem(String paramString)
  {
    View localView = getLayoutInflater().inflate(R.layout.category_item, this.listView, false);
    ((TextView)localView.findViewById(16908308)).setText(paramString);
    return localView;
  }

  protected View createEmptyItem()
  {
    View localView = new View(this);
    localView.setLayoutParams(new AbsListView.LayoutParams(-1, 24));
    return localView;
  }

  protected View getFailedView(String paramString, View.OnClickListener paramOnClickListener)
  {
    WeakReference localWeakReference = this.errorView;
    View localView1;
    if (localWeakReference != null)
      localView1 = (View)localWeakReference.get();
    else
      localView1 = null;
    if (localView1 == null)
    {
      localView1 = getLayoutInflater().inflate(R.layout.error_item, this.emptyView, false);
      this.errorView = new WeakReference(localView1);
    }
    ((TextView)localView1.findViewById(16908308)).setText(paramString);
    View localView2 = localView1.findViewById(R.id.btn_retry);
    int i;
    if (paramOnClickListener != null)
      i = 0;
    else
      i = 8;
    localView2.setVisibility(i);
    localView2.setOnClickListener(paramOnClickListener);
    localView2.requestFocus();
    return localView1;
  }

  protected View getLoadingView()
  {
    Object localObject = this.loadingView;
    if (localObject != null)
      localObject = (View)((WeakReference)localObject).get();
    else
      localObject = null;
    if (localObject == null)
    {
      localObject = getLayoutInflater().inflate(R.layout.loading_item, this.emptyView, false);
      this.loadingView = new WeakReference(localObject);
    }
    return (View)localObject;
  }

  public void onCreate(Bundle paramBundle)
  {
    super.onCreate(paramBundle);
    setupView();
    setEmptyView();
  }

  protected void setEmptyView()
  {
    this.listView = ((ListView)findViewById(R.id.list));
    this.emptyView = ((FrameLayout)findViewById(R.id.empty));
    this.listView.setEmptyView(this.emptyView);
  }

  protected void setupView()
  {
    setContentView(R.layout.list_frame);
  }
}
